package Q300;

import java.util.Arrays;

/**
 * 最长递增子序列
 *
 * @author 23737
 * @time 2021.11.27
 */
public class Test {
    public static void main(String[] args) {

    }
}

/**
 * dp
 */
class Solution {
    public int lengthOfLIS(int[] nums) {
        //define
        int[] dp = new int[nums.length];
        int result = 0;

        //init
        Arrays.fill(dp, 1);

        //dp
        for (int i = 0; i < nums.length; i++) {
            for (int j = 0; j <= i - 1; j++) {
                if (nums[i] > nums[j]) {
                    dp[i] = Math.max(dp[i], dp[j] + 1);
                }
            }
        }

        //result
        Arrays.sort(dp);
        result = dp[dp.length - 1];
        return result;
    }
}
